-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deterministic for
loops for dictionaries.
#240
Conversation
2dd1311
to
9c408d4
Compare
9dbab92
to
a3da20c
Compare
I think it's fine though I don't think this was mentioned anywhere in docs (I mean Stencil) that on dictionaries the order sill be deterministic. But this will preserve current behaviour at least. |
I think end users would expect consistent behaviour, no matter what the underlying (Swift) behaviour might be? |
And with the new swift hashing, we're forced to do something ourselves in this case. |
🤷♂️ depends on user understanding of nature of such types =) for some deterministic order in swift < 4.2 could be a surprise too =) |
@ilyapuchka I inadvertently merged this into the wrong branch 🤦♂️, so we should continue our discussion in #242. |
With Swift 4.2, hashing isn't consistent between runs anymore. A consequence of this is, if we iterate over a dictionary, the output won't always be the same, which will be unexpected for a user.
With this PR we iterate over the sorted keys of a dictionary, ensuring consistent output across runs.